import http from '@/utils/axios.util'
import type { resAppListInfosVo, resHotAppListVo } from '@/api/interface'
import type { AxiosResponse } from 'axios'

const $get =
  <T>(url: string) =>
  (options: any): Promise<AxiosResponse<T>> =>
    http({ url, params: options, method: 'GET' })
const $post =
  <T>(url: string) =>
  (data: any): Promise<AxiosResponse<T>> =>
    http({ url, data, method: 'POST' })
// 获取 热门 的列表
export const getHotAppList = (params = { limit: 10 }) =>
  $get<resHotAppListVo>(`/hk/rss/topgrossingapplications/limit=${params.limit}/json`)({})
//  获取 简单列表
export const getFreeAppList = (params = { limit: 10 }) =>
  $get<resHotAppListVo>(`/hk/rss/topfreeapplications/limit=${params.limit}/json`)({})
// https://itunes.apple.com/hk/lookup?id=${id}
export const getFreeListInfo = $get<resAppListInfosVo>(`/hk/lookup`)
